package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FileColumn;
import com.ruoyi.system.service.IFileColumnService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文件栏管理Controller
 *
 * @author ruoyi
 * @date 2024-03-25
 */
@RestController
@RequestMapping("/system/column")
public class FileColumnController extends BaseController
{
    @Autowired
    private IFileColumnService fileColumnService;

    /**
     * 查询文件栏管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:column:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody FileColumn fileColumn)
    {
        setStartPage(fileColumn.getPageNum(),fileColumn.getPageSize());
        List<FileColumn> list = fileColumnService.selectFileColumnList(fileColumn);
        return getDataTable(list);
    }


    /**
     * 获取文件栏管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:column:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fileColumnService.selectFileColumnById(id));
    }

    /**
     * 新增文件栏管理
     */
    @PreAuthorize("@ss.hasPermi('system:column:add')")
    @Log(title = "文件栏管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FileColumn fileColumn)
    {
        fileColumn.setCreateBy(getUsername());
        return fileColumnService.insertFileColumn(fileColumn);
    }

    /**
     * 修改文件栏管理
     */
    @PreAuthorize("@ss.hasPermi('system:column:edit')")
    @Log(title = "文件栏管理", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody FileColumn fileColumn)
    {
        return fileColumnService.updateFileColumn(fileColumn);
    }

    /**
     * 删除文件栏管理
     */
    @PreAuthorize("@ss.hasPermi('system:column:remove')")
    @Log(title = "文件栏管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(fileColumnService.deleteFileColumnById(id));
    }
}
